<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="<s:url value="/js/budget.js"/>"></script>
<style>
    #formBudget tr td{
        background: #F9F8E9;
    }
</style>

<div id="filter"  class="tableFilter">

    <div id="table_content">
    <table>
        <thead>
        <tr>
            <th>Country</th>
            <th>Date received</th>
            <th>Initial amount</th>
            <th>Date revised</th>
            <th>Revised amount</th>
            <th>Date final</th>
            <th>Final amount</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        <s:iterator value="budgets" var="bud">
        <tr>
            <th><s:property value="%{#bud.protocoloCompromisopais.compromisopais.country}"/></th>
            <th><s:date name="received" format="dd-MMM-yy" /></th>
            <th style="text-align: right"><s:if test='%{#bud.amountSbwinitial != null}'>U$S </s:if><s:property value="%{#bud.amountSbwinitial}"/></th>
            <th><s:date name="dateRevised" format="dd-MMM-yy" /></th>
            <th style="text-align: right"><s:if test='%{#bud.amountSbwrevised != null}'>U$S </s:if><s:property value="%{#bud.amountSbwrevised}"/></th>
            <th><s:date name="dateFinal" format="dd-MMM-yy" /></th>
            <th style="text-align: right"><s:if test='%{#bud.amountSbwfinal != null}'>U$S </s:if><s:property value="%{#bud.amountSbwfinal}"/></th>
            <th>
                <s:form action="main">
                    <s:hidden value="%{#bud.protocoloCompromisopais.compromisopais.id}" name="countryId"/>
                    <img src="<s:url value="/images/edit.png"/>" onclick="$(this).closest('form').submit()" alt="Edit"/>
                </s:form>
            </th>
        </tr>
        </s:iterator>
        </tbody>
    </table>
</div>

    <s:form id="form"  cssClass="tableEdit2" style="margin-top: 10%" >

    <tr>
        <th colspan="2" class="tableTitle">
            <h5>Protocol Budget</h5>
        </th>
    </tr>
    </s:form>

    <s:form id="formHidden" action="main">
        <s:hidden name="countryId" id="country"></s:hidden>
    </s:form>

    <s:form id="formBudget" cssClass="tableEdit2">
        <s:select label="Country" name="countryId" id="countryId" value="%{budget.protocoloCompromisopais.compromisopais.id}"
                  headerKey="" headerValue="Choose Country"
                  list="paisList"
                  listKey="id"
                  listValue="country"
                  onchange="getBudgetForCountry(this.value)">
        </s:select>

        <s:hidden name="budget.id" value="%{budget.id}"/>

        <s:hidden name="budget.received" id="altdReceived" value="%{budget.received}"/>
        <s:textfield label="Received" id="dReceived" cssClass="datepicker"/>

        <s:textfield label="Amount SBW Initial (U$S)" name="sbwInitial"  value="%{sbwInitial}"/>

        <s:hidden name="budget.dateRevised" id="altdRevised" value="%{budget.dateRevised}"/>
        <s:textfield label="Date Revised" id="dRevised" cssClass="datepicker"/>

        <s:textfield label="Amount SBW Revised (U$S)" name="sbwRevised"  value="%{sbwRevised}"/>

        <s:hidden name="budget.dateFinal" id="altdFinal" value="%{budget.dateFinal}"/>
        <s:textfield label="Date Final" id="dFinal" cssClass="datepicker"/>

        <s:textfield label="Amount SBW Final (U$S)" name="sbwFinal" value="%{sbwFinal}"/>

    <tr>
        <td colspan="2" class="centeredButtons" ><s:submit value="Save" id="save" action="save" onclick="validate();" theme="simple"/>
            <s:submit action="clean" value="New" id="new" theme="simple"/></td>
    </tr>

</s:form>
    </div>


<script type="text/javascript">
    $('#protocolBudget').css({"color":"#EE5102","fontWeight":"bold"});
</script>
